<?php
/**
 * Class AdminAuth
 * 后台请求合法行验证
 */

namespace app\upms;


use app\common\utils\ReturnCode;

class AdminAuth
{
    public function run(&$params)
    {
        if (request()->pathinfo() != 'admin/login/login') {
            $token = request()->header('token', '');
            if (empty($token) || !cache($token) || request()->isOptions()) {
                $result['code'] = ReturnCode::ACCESS_TOKEN_TIMEOUT;
                $result['msg'] = '请求不合法';
                exit(json_encode($result));
            }
        }
    }

}